package cn.fourhundredandeighteen.controller;

import cn.fourhundredandeighteen.service.AdminService;
import cn.fourhundredandeighteen.service.StudentService;
import cn.fourhundredandeighteen.service.TeacherService;
import cn.fourhundredandeighteen.service.impl.AdminServiceImpl;
import cn.fourhundredandeighteen.service.impl.StudentServiceImpl;
import cn.fourhundredandeighteen.service.impl.TeacherServiceImpl;
import cn.fourhundredandeighteen.utill.Result;
import cn.fourhundredandeighteen.utill.ResultGenerator;
import cn.fourhundredandeighteen.view.vo.LoginVO;


/**
 * @description:
 * @author: liuyongqi
 * @time: 2020/12/16
 */
public class Login {
    /**
     * 学生登录接口
     * @param loginVO
     * @return 学生姓名
     * 功能已添加
     */
    public Result<String> studentLogin(LoginVO loginVO){
        StudentService studentService=new StudentServiceImpl();
        String login = studentService.login(loginVO);
        if (login!=null){
            return ResultGenerator.successResult(login);
        }else {
            return ResultGenerator.errorResult();
        }
    }

    /**
     * 教师登录接口
     * @param loginVO
     * @return 教师名称
     * 功能已添加
     */
    public Result<String> teacherLogin(LoginVO loginVO){
        TeacherService teacherService=new TeacherServiceImpl();
        String login = teacherService.login(loginVO);
        if (login!=null){
            return ResultGenerator.successResult(login);
        }else {
            return ResultGenerator.errorResult();
        }
    }

    /**
     * 管理员登陆
     * @param loginVO
     * @return
     * 功能已添加
     */
    public Result<String> AdminLogin(LoginVO loginVO){
        AdminService adminService=new AdminServiceImpl();
        String s = adminService.loginAdmin(loginVO);
        if (s==null)
            return ResultGenerator.errorResult();
        else
            return ResultGenerator.successResult(s);
    }
}
